/**
 * 删除两个旗帜之间的建筑
 */
export const removeStructureBetweenFlags = function (
    flag1: Flag,
    flag2: Flag,
    type?: StructureConstant,
    removeFunc?: (structure: Structure) => void,
) {
    if (!removeFunc) {
        removeFunc = (structure) => structure.destroy()
    }

    const pos1 = flag1.pos
    const pos2 = flag2.pos
    const minX = Math.min(pos1.x, pos2.x)
    const minY = Math.min(pos1.y, pos2.y)
    const maxX = Math.max(pos1.x, pos2.x)
    const maxY = Math.max(pos1.y, pos2.y)
    const room = Game.rooms[pos1.roomName]
    const structures = room.lookForAtArea(LOOK_STRUCTURES, minY, minX, maxY, maxX, true)
    for (const structure of structures) {
        if (type && structure.structure.structureType !== type) continue
        removeFunc(structure.structure)
    }
}
